
<template>
  <h1>mapState映射的数据也不具备响应式</h1>
  <h2>年龄: {{age}}</h2>
  <h3>名字: {{name}}</h3>
  <button @click="setPeopleInfo('问问','18')">点我改变people</button>
  <button @click="z_setPeopleInfoObj({name:'文文',age:19})">别名修改people</button>
</template>
<script >
import {mapActions, mapState} from 'pinia'
import { usePeopleStore } from "../stores/usePeopleStore";

export default {
  computed:{
    ...mapState(usePeopleStore,['age','name'])
  },
  methods:{
    // mapActions映射为自己的函数
    // 1.0 字符串模式
    ...mapActions(usePeopleStore,['setPeopleInfo']),
    // 2.0 对象模式 可以用别名
    ...mapActions(usePeopleStore,{
      z_setPeopleInfoObj:'setPeopleInfoObj'
    })
  }
}

</script>
